TruncText function

Syntax
TruncText width, where, text [, fontname] [, size] [, style]

Description
Truncates a line of text in the given fontname, size, and style so that it fits within width pixels and returns the truncated text, or the original text if no truncation is necessary.

Where indicates where the truncation should occur: 0 (zero) for the end of the text or 1 for the middle. TruncText places an ellipsis character (…) at the point where the truncation occurred, if any.

If you omit any of the optional parameters, TruncText uses default values of Geneva, 9-point, plain style in place of any missing parameters.

The style parameter is a number you can specify yourself or get from a button's .TextStyle property. Add style numbers together to combine styles.

0: Plain Text
1: Bold
2: Italic
4: Underline
8: Outline
16: Shadow
32: Condense
64: Extend

Examples
// Truncate a button's text so that it fits within the button's width.
// Allow extra room for the button's border width, which can be
// anywhere from 3 to 17 pixels depending on the border style.
Variable Extra 
Extra = 7            // left + right border widths
With Button
     .Border = 1
     .Text = TruncText .Width - Extra, 0, .Text, .TextFont, .TextSize, .TextStyle
End With 

Author Info
TruncText, part of FitText Extension
Copyright © 1999 Jeff Jungblut. All rights reserved.

See Also
TextWidth function (page 296), Button object (page 176)